const state = () => ({
  masterTabIndex: 1, //circleMater的tab导航条选中
  authFromPageType: 0, //circleFeed页面是从哪个页面页面跳转过来 0表示不是从任何页面过来  1 从circleMaster过来
  isFromRenew: 0, //是否是续费
  isFromLearnJump: 0, // 是否是来自学习跳转
  circleRecommendList: JSON.parse(localStorage.getItem("circle_release_draft")) ? (JSON.parse(localStorage.getItem("circle_release_draft")).circleRecommendList || []) : [], //圈子推荐课程选中数据
})

const mutations = {
  updateMasterTabIndex(state, val) {
    state.masterTabIndex = val;
  },
  updateAuthFromPageType(state, val) {
    state.authFromPageType = val;
  },
  updateFromRenew(state, val) {
    state.isFromRenew = val;
  },
  updateFromLearnJump(state, val) {
    state.isFromLearnJump = val
  },
  updateCircleRecommendList(state, val) {
    if (val && val.length) {
      let circleRelease = JSON.parse(localStorage.getItem("circle_release_draft")) || {};
      circleRelease["circleRecommendList"] = val;
      localStorage.setItem("circle_release_draft", JSON.stringify(circleRelease));
    }
    state.circleRecommendList = val
  },
}

export default {
  namespaced: true,
  state,
  mutations
}